//
//  ZGLPicCollectionViewCell.m
//  Faker
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ZGLPicCollectionViewCell.h"
#import "ZGLPicVCModel.h"
#import <UIImageView+AFNetworking.h>

@interface ZGLPicCollectionViewCell () 

@property (nonatomic, strong) UIImageView *bigImage;
@property (nonatomic, strong) UILabel *wordLabel;

@end

@implementation ZGLPicCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        _bigImage = [[UIImageView alloc] init];
        _wordLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_bigImage];
        [self.contentView addSubview:_wordLabel];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.backgroundColor = foreColor;
    [_bigImage setFrame:CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height)];
    [_wordLabel setFrame:CGRectMake(ScaleX * 10, ScaleY * 100, ScaleX * 160, ScaleY * 40)];
    _wordLabel.numberOfLines = 2;
    _wordLabel.textColor = [UIColor whiteColor];
    _wordLabel.font = [UIFont systemFontOfSize:13];
    _wordLabel.shadowColor =[UIColor blackColor];
    _wordLabel.shadowOffset = CGSizeMake(0.3, 0.3);
}

- (void)setPicModel:(ZGLPicVCModel *)picModel {
    if (_picModel != picModel) {
        _picModel = picModel;
    }
    [_bigImage setImageWithURL:[NSURL URLWithString:picModel.media[0][@"s_url"]] placeholderImage:[UIImage imageNamed:@"nopic"]];
    _wordLabel.text = picModel.title;
}

@end
